/**
 * 
 * 
 * Created on 30 apr. 2011 @ 15:20:43 by Laurens Andriessen
 */

package tests.laurens.cajomulticasting;

import gnu.cajo.utils.Multicast;


/**
 * 
 * @author Laurens Andriessen
 * @version 1.0
 */
public class MultiCastClient {

	/**
	 * 
	 * @author Laurens Andriessen
	 * @param args
	 */
	static Object object = new MultiCastClient();

	public Object multicast(Multicast m) { // multicast listener callback
		try {
			System.out.println(m.item.invoke("doit", "hello!"));
		} catch (Exception x) {
			x.printStackTrace();
		}
		synchronized (this) {
			notify();
		} // end program
		return this; // stop listening, else return null
	}

	public static void main(String args[]) throws Exception { // unit test
		Multicast m = new Multicast();
		m.listen(object);
		synchronized (object) {
			object.wait();
		}
	}
}
